﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EvidenceLib.System;
using EvidenceService.Core;
using NHibernate;

namespace EvidenceService.System
{
    /// <summary>
    /// 组织结构数据服务
    /// </summary>
    public class OrganizationService : BasicService<Organization>
    {
        public OrganizationService(ISession session)
            : base(session)
        {

            
        }

        public override IList<Organization> LoadByHQL(string hql)
        {
            IList<Organization> orgs = base.LoadByHQL(hql);

            foreach(Organization org in orgs)
            {
                org.Name = SubName(org.Name);
            }

            return orgs;
        }

        private string SubName(string name)
        {
            string result=null;

            if (name != null)
            {
                int begin =name.IndexOf("青羊区分局");

                if (begin == 0)
                    result = name.Substring(5);
                else
                    result = name;
                    
            }

            return result;
        }
    }
}
